Public Class editright
    Inherits System.Web.UI.Page

    'Protected WithEvents TheHeader1 As adm_header
    Public Msg, vid, uid, s, typename, strTitle As String
    Public aUserSession(13) As String
    'Public oUtils As utils
    Public grantedYes, deniedYes As Boolean
    Public aPermission, rst As Array
    Public txtPmType(3) As String
    Public i, tidcct As Integer
    Public srePermVirTyp, strPermUerTyp, strPermTermSetup As String
    Protected WithEvents denied As System.Web.UI.WebControls.RadioButton
    Protected WithEvents BtnModify As System.Web.UI.WebControls.Button
    Protected WithEvents BtnCancel As System.Web.UI.WebControls.Button
    Protected WithEvents granted As System.Web.UI.WebControls.RadioButton
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        'If aUserSession(cCOMPANY_ID) = "0" Then
        '    cid = safestring(Request("cid"))
        'Else
        '    cid = Application("CompanyID")
        'End If
        'If Request("vid").count > 0 Then
        '    vid = safestring(Request("vid"))
        '    uid = safestring(Request("uid"))
        'Else
        '    vid = aUserSession(cVIAKLIX_ID)
        '    uid = aUserSession(cUSER_ID)
        'End If
        'Dim aRights

        txtPmType(0) = "Virtual Terminal"
        txtPmType(1) = "User Management"
        txtPmType(2) = "Terminal Setup"
        'TheHeader1.whichpage = 54
        'TheHeader1.pageid = "findusers"
        'TheHeader1.helpaid = ""
        'TheHeader1.iMenuLevel = 7
        'aUserSession = TheHeader1.security()
        'TheHeader1.StartInterface(54)
        'TheHeader1.intTopNavLev = 1 '''aTopNav(0, 5) = 1
        GetUserPermissions()
        

    End Sub
    Private Sub GetUserPermissions()
        '      oRights = CreateObject("viaUserManagement.UserPermission")
        '      oRights.DBConnectString = Application("DSN")
        '      oRights.SESSION_USER_ID = aUserSession(cUSER_ID)
        '      oRights.SESSION_VIAKLIX_ID = aUserSession(cVIAKLIX_ID)
        'aPermission = oRights.GetUserPermissions(uid, vid, Cint(cid))%>


    End Sub
    'Public Function GetPermissionTypes(ByVal i As Integer) As String
    '    txtPmType(0) = "Virtual Terminal"
    '    txtPmType(1) = "User Management"
    '    txtPmType(2) = " Terminal Setup"

    'oRights = CreateObject("viaUserManagement.UserPermission")
    'oRights.DBConnectString = Application("DSN")
    'oRights.SESSION_USER_ID = aUserSession(cUSER_ID)
    'oRights.SESSION_VIAKLIX_ID = aUserSession(cVIAKLIX_ID)
    'rst = oRights.GetPermissionTypes(uid, vid, cid, txtPmType(i))
    'rst = oRights.GetPermissionTypes(uid, vid, cid, "virtualterminaltype")
    '****virtualterminaltype***
    '     if Isarray(rst) then%>
    '	srePermVirTyp="<table width="100%" cellspacing="0" class="minorbox">

    '	 <tr>
    ' 		<td colspan="3" class="header">Virtual Terminal</td>
    '		</tr>

    '	<%For i = 0 to ubound(rst)-1
    '         For ctr = 0 To UBound(aPermission)
    '             granted = ""
    '             denied = ""
    '             If Safestring(aPermission(ctr, 0)) = uid And CInt(aPermission(ctr, 1)) = CInt(rst(i, 0)) Then
    '                 granted = "checked"
    '                 Exit For
    '             Else
    '                 denied = "checked"
    '             End If
    '			next%>
    '<tr>
    '		<td><input type="radio" name="<%=rst(i,0)%>" value="N" <%=denied%>>No</td>
    '		<td><input type="radio" name="<%=rst(i,0)%>" value="Y" <%=granted%>>Yes</td>
    '		<td><%=rst(i,1)%></td>
    '	</tr>
    '<%NEXT%>
    'typename=rst(i,1)
    '</table>
    '<br />
    '<%end if
    '******end******
    '******usermngttype***
    '     rst = oRights.GetPermissionTypes(uid, vid, cid, "usermngttype")
    '	if Isarray(rst) then%>

    'strPermUerTyp="<table width="100%" cellspacing="0" class="minorbox">

    '	 <tr>
    ' 		<td colspan="3" class="header">User Management</td>
    '		</tr>

    '	  <%For i = 0 to ubound(rst)-1
    '         For ctr = 0 To UBound(aPermission)
    '             granted = ""
    '             denied = ""
    '             If Safestring(aPermission(ctr, 0)) = uid And CInt(aPermission(ctr, 1)) = CInt(rst(i, 0)) Then
    '                 granted = "checked"
    '                 Exit For
    '             Else
    '                 denied = "checked"
    '             End If
    '         Next
    '%>

    '  <tr>
    '	<td><input type="radio" name="<%=rst(i,0)%>" value="N" <%=denied%>>No</td>
    '	<td><input type="radio" name="<%=rst(i,0)%>" value="Y" <%=granted%>>Yes</td>
    '	<td><%=rst(i,1)%></td>
    ' </tr>

    '      <%NEXT%>

    '    	</table>
    '<br />
    '<%end if
    '****terminalSetup*****
    '     rst = oRights.GetPermissionTypes(uid, vid, cid, "terminalsetup")
    '	if Isarray(rst) then%>

    'strPermTermSetup="<table width="100%" cellspacing="0" class="minorbox">

    '	 <tr>
    ' 		<td colspan="3" class="header">Terminal Setup</td>
    '		</tr>

    '		<%For i = 0 to ubound(rst)-1
    '         For ctr = 0 To UBound(aPermission)
    '             granted = ""
    '             denied = ""
    '             If Safestring(aPermission(ctr, 0)) = uid And CInt(aPermission(ctr, 1)) = CInt(rst(i, 0)) Then
    '                 granted = "checked"
    '                 Exit For
    '             Else
    '                 denied = "checked"
    '             End If
    '			next%>


    '  <tr>
    '	<td><input type="radio" name="<%=rst(i,0)%>" value="N" <%=denied%>>No</td>
    '	<td><input type="radio" name="<%=rst(i,0)%>" value="Y" <%=granted%>>Yes</td>
    '	<td><%=rst(i,1)%></td>
    '</tr>

    '  <%NEXT%>

    '    	</table>
    '<br />
    '<%end if%>
    '<%for i=0 to 2 
    '        GetPermissionTypes(txtPmType(i))
    '							if Not Isnothing(rst) then%>
    '						</table>
    '						<table class="minorbox" cellSpacing="0" width="100%">
    '							<tr>
    '								<td class="header" colSpan="3"><%=txtPmType(i)%></td>
    '							</tr>
    '							<tr>
    '								<td><asp:radiobutton id="denied"  Text="No" Runat="server" Checked="True"></asp:radiobutton></td>
    '								<td><asp:radiobutton id="granted" Text="Yes" Runat="server" Checked="True"></asp:radiobutton></td>
    '								<!--<td><%=rst(i,1)%></td>--></tr>
    '						</table>
    '						<%NEXT%>
    ' End Function


    Private Sub BtnModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnModify.Click
        'If Request("action") = "Modify" Then
        '    sNewRights = Request.Form
        '    aNewRights = Split(sNewRights, "&")
        '    For ctr = 0 To UBound(aNewRights)
        '        If InStr(aNewRights(ctr), "=Y") > 0 Or InStr(aNewRights(ctr), "=N") > 0 Then
        '            If InStr(aNewRights(ctr), "=Y") > 0 Then
        '                grant = grant & Left(aNewRights(ctr), Len(aNewRights(ctr)) - 2) & ","
        '            Else
        '                revoke = revoke & Left(aNewRights(ctr), Len(aNewRights(ctr)) - 2) & ","
        '            End If
        '        End If
        '    Next

        '    If Len(grant) > 1 Then
        '        grant = Left(grant, Len(grant) - 1)
        '    End If

        '    If Len(revoke) > 1 Then
        '        revoke = Left(revoke, Len(revoke) - 1)
        '    End If

        '    oupd = CreateObject("viaUserManagement.UserPermission")
        '    oupd.DBConnectString = Application("DSN")
        '    oupd.SESSION_USER_ID = aUserSession(cUSER_ID)
        '    oupd.SESSION_VIAKLIX_ID = aUserSession(cVIAKLIX_ID)
        '    'oupd.SESSION_COMPANY_ID=aUserSession(cCOMPANY_ID)
        '    oupdOk = oupd.UpdateUserpermissions(uid, cid, vid, grant, revoke)
        '    If oupdOk Then
        '        notifymsg = "User Rights susccessfully updated."
        '    Else
        '        Msg = "User cannot get this permission."
        '    End If
        'End If

    End Sub

    Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
        Response.Redirect("")
    End Sub
End Class
